package userTests;

import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
import static org.testng.Assert.*;

import java.util.concurrent.TimeUnit;
import java.util.Date;
import java.io.File;
import org.openqa.selenium.support.ui.Select;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.*;
import static org.openqa.selenium.OutputType.*;

public class DocUploadTests extends TestBaseUser {

	@Test
	public void testDocUpload() {
		openMainPageUser();
		gotoSignInUser();
		LoginLogoutDataUser login = new LoginLogoutDataUser();
		login.phoneNumber = "955413233";
		login.password = "!23Qwe";
		fillSignInUser(login);
		submitSignInUser();

		gotoDocumentUploader();

//		 wd.findElement(By.cssSelector(a[href="/cabinet/document/uploader"])).click();

		refreshDocumentsList();

//	    wd.findElement(By.cssSelector("label")).click();
		wd.findElement(By.cssSelector("label+Upload")).click();
		wd.findElement(By.id("dropbox")).click();
		wd.findElement(By.id("fileElem")).click();
		wd.findElement(By.id("reload-link")).click();
		wd.findElement(By.id("upload-ok-link")).click();
		wd.findElement(By.cssSelector("span.label.label-inverse")).click();
	}

	private void refreshDocumentsList() {
		wd.findElement(By.id("documents_list_refresh")).click();
	}

	// private void gotoDocumentUploader() {
	// wd.findElement(By.id("sidebarLinkWmtCabinetDocumentUploader")).click();
	// }
	private void gotoDocumentUploader() {
		wd.get("http://testwmt.wdev.com.ua/cabinet/document/uploader");
	}
}
